/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Home
 */
@Entity
@Table(name = "periferico", catalog = "sna2", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Periferico.findAll", query = "SELECT p FROM Periferico p"),
    @NamedQuery(name = "Periferico.findByCardID", query = "SELECT p FROM Periferico p WHERE p.cardID = :cardID"),
    @NamedQuery(name = "Periferico.findByTipo", query = "SELECT p FROM Periferico p WHERE p.tipo = :tipo"),
    @NamedQuery(name = "Periferico.findByCodigo", query = "SELECT p FROM Periferico p WHERE p.codigo = :codigo")})
public class Periferico implements Serializable {
    private static final long serialVersionUID = 1L;
    @Size(max = 20)
    @Column(name = "card_ID")
    private String cardID;
    @Size(max = 20)
    @Column(name = "tipo")
    private String tipo;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "codigo")
    private String codigo;
    @JoinColumn(name = "codigo_computadora", referencedColumnName = "codigo")
    @ManyToOne(optional = false)
    private Computadoras computadoras;

    public Periferico() {
    }

    public Periferico(String codigo) {
        this.codigo = codigo;
    }

    public String getCardID() {
        return cardID;
    }

    public void setCardID(String cardID) {
        this.cardID = cardID;
    }

    public String getTipo() {
        return tipo;
    }

    public void setTipo(String tipo) {
        this.tipo = tipo;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public Computadoras getComputadoras() {
        return computadoras;
    }

    public void setComputadoras(Computadoras computadoras) {
        this.computadoras = computadoras;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codigo != null ? codigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Periferico)) {
            return false;
        }
        Periferico other = (Periferico) object;
        if ((this.codigo == null && other.codigo != null) || (this.codigo != null && !this.codigo.equals(other.codigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Periferico[ codigo=" + codigo + " ]";
    }
    
}
